package com.hiwan.unions.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.hiwan.unions.R;
import com.hiwan.unions.activity.main.homeInform.InformActivity;
import com.hiwan.unions.activity.system.FeedbackActivity;
import com.hiwan.unions.adapter.fragmentAdapters.FragmentAdapter_gridview;
import com.hiwan.unions.util.PerfectClickListener;
import com.hiwan.unions.util.StartIntent;
import com.hiwan.unions.util.Utils;

/**
 * Created by llg on 2017/7/8.
 */
public class SearchDialog extends Dialog {
    private GridView gridView;
    private FragmentAdapter_gridview adapter_gridview;
    private int i = 0;


    public SearchDialog(final Context context, int[] cDates, final String[] strings) {
        super(context, R.style.searchDialog);
        setContentView(R.layout.dialog_search);
        adapter_gridview = new FragmentAdapter_gridview(context);
        gridView = (GridView) findViewById(R.id.gridview_top);
        gridView.setAdapter(adapter_gridview);
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (strings[position].equals("往期动态")) {
                    InformActivity.startPreview(context, i);
                    dismiss();
                } else {
                    boolean type = StartIntent.get(context).contentStart(strings[position]);
                    if (type)
                        dismiss();
                }
            }
        });
        adapter_gridview.setDates(strings, cDates);
        this.setCanceledOnTouchOutside(false);
        findViewById(R.id.image_off).setOnClickListener(new PerfectClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                dismiss();
            }
        });
    }

    public void show(int i) {
        this.i = i;
        show();
    }
}